


TFSIM_PATH=../../tfsim/install

C_SOURCES=$(wildcard *.c)
CPP_SOURCES=$(wildcard *.cpp)
O_OBJECTS=$(patsubst %.c,%.o,$(C_SOURCES))
OPP_OBJECTS=$(patsubst %.cpp,%.opp,$(CPP_SOURCES))

CFLAGS=-O0 -g

all : libdfrt.so libdfrt.a


libevent.so : event_manager.opp nodelevel_aggregator.opp dfruntime.o
	g++  $(CFLAGS)  -shared  -rdynamic -fopenmp  $^ -o $@  -ldl -Wl,-rpath,.:$(TFSIM_PATH)/lib -L. 
	

#Add -ltf to link with tfsim
libdfrt.so : $(O_OBJECTS) $(OPP_OBJECTS)
	g++  $(CFLAGS)  -shared  -rdynamic -fopenmp  $^ -o $@  -ldl -Wl,-rpath,.:$(TFSIM_PATH)/lib -L.

libdfrt.a : $(O_OBJECTS) $(OPP_OBJECTS)
	ar rcs $@ $^

%.o : %.c
	gcc  $(CFLAGS)  -rdynamic -DUSE_NATIVE -DTF_GUEST_NATIVE -c -fPIC -fopenmp -I. -I$(TFSIM_PATH)/include $< -Wall -Werror -Wextra -Wno-unused -std=gnu99 -o $@

%.opp : %.cpp
	g++  $(CFLAGS) -std=c++0x -fopenmp -rdynamic -DUSE_NATIVE -DTF_GUEST_NATIVE -c -fPIC -I. -I$(TFSIM_PATH)/include $< -Wall -Werror -Wextra -Wno-unused -o $@





.PHONY : clean
clean :
	rm -rf *.opp *.o libdfrt.so libevent.so
